@extends('admin.layout.index')
@section('js')
<script src="/web/js/libs/jquery-1.8.3.min.js"></script>
<script>
$(function (){
    $('input[name=cname]').blur(function (){
        val = $(this).val();
        $.get('/admin/cate/verify','cname='+val, function (msg){
            if(msg == 1){
                $('#text').empty().append('<font style="color:red">分类名已存在</font>')
            }
        },'html')

    })
})
</script>
@endsection
@section('content')
@if (count($errors) > 0)
    <div class="mws-form-message error">
        <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif
<div class="mws-panel grid_8">
	<div class="mws-panel-header">
    	<span>分类添加</span>
    </div>
    <div class="mws-panel-body no-padding">
    	<form action="/admin/cate/insert" class="mws-form" method='post'>
    		{{csrf_field()}}
    		<div class="mws-form-inline">
    			<div class="mws-form-row">
    				<label class="mws-form-label">分类名称</label>
    				<div class="mws-form-item">
    					<input type="text" class="small" name="cname">
                             <span id='text'></span>
    				</div>
    			</div>
    			<div class="mws-form-row">
    				<label class="mws-form-label">分类所属组</label>
    				<div class="mws-form-item">
<<<<<<< HEAD
    					<select class="large" name="pid" style="width:55%">
=======
    					<select class="large" name="pid">
>>>>>>> 31e42f2d3415b82d4888522298db4e7de5f9c8aa
    					<option>--请选择--</option>
    					@foreach($data as $k => $v)
    						<option value="{{$v['id']}}" @if($id == $v['id']) selected @endif>{{$v['cname']}}</option>
    					@endforeach
    					</select>
    				</div>
    			</div>
    		</div>
    		<div class="mws-button-row">
    			<input type="submit" class="btn btn-danger" value="添加">
    			<input type="reset" class="btn " value="重置">
    		</div>
    	</form>
    </div>    	
</div>
@endsection
